package net.cassite.daf4j;

/**
 * 事务处理类
 */
public class Tx {
        private boolean active;

        private final DataAccess dataAccess;

        Tx(DataAccess dataAccess) {
                this.dataAccess = dataAccess;
                active = true;
        }

        /**
         * 提交事务
         */
        public void commit() {
                dataAccess.txCommit();
                active = false;
        }

        /**
         * 回滚事务
         */
        public void rollback() {
                dataAccess.txRollback();
                active = false;
        }

        public boolean isActive() {
                return active;
        }

        public boolean isClosed() {
                return !isActive();
        }
}
